<?php

namespace html;

use Classes\autoload\SplClassLoader;
use Classes;
use Classes\User;
use PDO;
use Classes\Post;
use Classes\City;

class ProfileView {
	public static function showPosts($user_id) {
		$posts = Post::getWallPosts ( $user_id );
		
		if (isset ( $_SESSION ['userPrincipal'] )) {
			$userPrincipal = $_SESSION ['userPrincipal'];
		}
		
		foreach ( $posts as $post ) {
			echo '<div class="post-div">';
			echo '<p><a href="?profile=' . $post ['author'] . '">' . $post ['user_name'] . '</a></p>';
			echo '<p>' . $post ['content'] . '</p>';
			echo '<p>' . $post ['date'] . '</p>';
			if ($post ['author'] == $userPrincipal->getUserId () || $userPrincipal->getRank () == 10) {
				echo '<p><a href="?deletepost=yes&post_id=' . $post ['post_id'] . '">Изтрий</a></p>';
			}
			echo '</div>';
		}
	}
	public static function showUserInfo($user_id) {
		$user = Classes\User::getUser ( $user_id );
		$city = Classes\City::getCity ( $user ['city'] );
		$city = $city ['city_name'];
		
		echo '<h3>' . $user ['user_name'] . '</h3>';
		echo '<p>От ' . $city . '</p>';
		if ($user ['playing'] == 0) {
			echo '<p>Не играе футбол</p>';
		} else {
			$club = Classes\Club::getClub ( $user ['playing_club'] );
			echo '<p>Състезава се като футболист за ' . $club ['club_name'] . '</p>';
		}
		$club = Classes\Club::getClub ( $user ['favorite_club'] );
		echo '<p>Любим отбор: ' . $club ['club_name'] . '</p>';
	}
}
